.class public Lcom/philzhu/www/framework/impl/AndroidFastRenderView;
.super Landroid/view/SurfaceView;
.source "AndroidFastRenderView.java"

# interfaces
.implements Ljava/lang/Runnable;


# instance fields
.field framebuffer:Landroid/graphics/Bitmap;

.field game:Lcom/philzhu/www/framework/impl/AndroidGame;

.field holder:Landroid/view/SurfaceHolder;

.field renderThread:Ljava/lang/Thread;

.field volatile running:Z


# direct methods
.method public constructor <init>(Landroid/content/Context;Landroid/util/AttributeSet;)V
    .locals 1
    .parameter "context"
    .parameter "attrs"

    .prologue
    .line 20
    invoke-direct {p0, p1, p2}, Landroid/view/SurfaceView;-><init>(Landroid/content/Context;Landroid/util/AttributeSet;)V

    .line 15
    const/4 v0, 0x0

    iput-object v0, p0, Lcom/philzhu/www/framework/impl/AndroidFastRenderView;->renderThread:Ljava/lang/Thread;

    .line 17
    const/4 v0, 0x0

    iput-boolean v0, p0, Lcom/philzhu/www/framework/impl/AndroidFastRenderView;->running:Z

    .line 21
    invoke-virtual {p0}, Lcom/philzhu/www/framework/impl/AndroidFastRenderView;->getHolder()Landroid/view/SurfaceHolder;

    move-result-object v0

    iput-object v0, p0, Lcom/philzhu/www/framework/impl/AndroidFastRenderView;->holder:Landroid/view/SurfaceHolder;

    .line 22
    return-void
.end method


# virtual methods
.method public initView(Lcom/philzhu/www/framework/impl/AndroidGame;Landroid/graphics/Bitmap;)V
    .locals 0
    .parameter "game"
    .parameter "frameBuffer"

    .prologue
    .line 26
    iput-object p1, p0, Lcom/philzhu/www/framework/impl/AndroidFastRenderView;->game:Lcom/philzhu/www/framework/impl/AndroidGame;

    .line 27
    iput-object p2, p0, Lcom/philzhu/www/framework/impl/AndroidFastRenderView;->framebuffer:Landroid/graphics/Bitmap;

    .line 28
    return-void
.end method

.method public pause()V
    .locals 1

    .prologue
    .line 57
    const/4 v0, 0x0

    iput-boolean v0, p0, Lcom/philzhu/www/framework/impl/AndroidFastRenderView;->running:Z

    .line 60
    :goto_0
    :try_start_0
    iget-object v0, p0, Lcom/philzhu/www/framework/impl/AndroidFastRenderView;->renderThread:Ljava/lang/Thread;

    invoke-virtual {v0}, Ljava/lang/Thread;->join()V
    :try_end_0
    .catch Ljava/lang/InterruptedException; {:try_start_0 .. :try_end_0} :catch_0

    .line 66
    return-void

    .line 62
    :catch_0
    move-exception v0

    goto :goto_0
.end method

.method public resume()V
    .locals 1

    .prologue
    .line 31
    const/4 v0, 0x1

    iput-boolean v0, p0, Lcom/philzhu/www/framework/impl/AndroidFastRenderView;->running:Z

    .line 32
    new-instance v0, Ljava/lang/Thread;

    invoke-direct {v0, p0}, Ljava/lang/Thread;-><init>(Ljava/lang/Runnable;)V

    iput-object v0, p0, Lcom/philzhu/www/framework/impl/AndroidFastRenderView;->renderThread:Ljava/lang/Thread;

    .line 33
    iget-object v0, p0, Lcom/philzhu/www/framework/impl/AndroidFastRenderView;->renderThread:Ljava/lang/Thread;

    invoke-virtual {v0}, Ljava/lang/Thread;->start()V

    .line 34
    return-void
.end method

.method public run()V
    .locals 7

    .prologue
    const/4 v6, 0x0

    .line 38
    invoke-static {}, Ljava/lang/System;->nanoTime()J

    move-result-wide v2

    .line 39
    .local v2, startTime:J
    :cond_0
    :goto_0
    iget-boolean v4, p0, Lcom/philzhu/www/framework/impl/AndroidFastRenderView;->running:Z

    if-nez v4, :cond_1

    .line 54
    return-void

    .line 40
    :cond_1
    iget-object v4, p0, Lcom/philzhu/www/framework/impl/AndroidFastRenderView;->holder:Landroid/view/SurfaceHolder;

    invoke-interface {v4}, Landroid/view/SurfaceHolder;->getSurface()Landroid/view/Surface;

    move-result-object v4

    invoke-virtual {v4}, Landroid/view/Surface;->isValid()Z

    move-result v4

    if-eqz v4, :cond_0

    .line 43
    invoke-static {}, Ljava/lang/System;->nanoTime()J

    move-result-wide v4

    sub-long/2addr v4, v2

    long-to-float v4, v4

    const v5, 0x4e6e6b28

    div-float v1, v4, v5

    .line 44
    .local v1, deltaTime:F
    invoke-static {}, Ljava/lang/System;->nanoTime()J

    move-result-wide v2

    .line 46
    iget-object v4, p0, Lcom/philzhu/www/framework/impl/AndroidFastRenderView;->game:Lcom/philzhu/www/framework/impl/AndroidGame;

    invoke-virtual {v4}, Lcom/philzhu/www/framework/impl/AndroidGame;->getCurrentScreen()Lcom/philzhu/www/framework/Screen;

    move-result-object v4

    invoke-virtual {v4, v1}, Lcom/philzhu/www/framework/Screen;->update(F)V

    .line 47
    iget-object v4, p0, Lcom/philzhu/www/framework/impl/AndroidFastRenderView;->game:Lcom/philzhu/www/framework/impl/AndroidGame;

    invoke-virtual {v4}, Lcom/philzhu/www/framework/impl/AndroidGame;->getCurrentScreen()Lcom/philzhu/www/framework/Screen;

    move-result-object v4

    invoke-virtual {v4, v1}, Lcom/philzhu/www/framework/Screen;->present(F)V

    .line 49
    iget-object v4, p0, Lcom/philzhu/www/framework/impl/AndroidFastRenderView;->holder:Landroid/view/SurfaceHolder;

    invoke-interface {v4}, Landroid/view/SurfaceHolder;->lockCanvas()Landroid/graphics/Canvas;

    move-result-object v0

    .line 51
    .local v0, canvas:Landroid/graphics/Canvas;
    iget-object v4, p0, Lcom/philzhu/www/framework/impl/AndroidFastRenderView;->framebuffer:Landroid/graphics/Bitmap;

    const/4 v5, 0x0

    invoke-virtual {v0, v4, v6, v6, v5}, Landroid/graphics/Canvas;->drawBitmap(Landroid/graphics/Bitmap;FFLandroid/graphics/Paint;)V

    .line 52
    iget-object v4, p0, Lcom/philzhu/www/framework/impl/AndroidFastRenderView;->holder:Landroid/view/SurfaceHolder;

    invoke-interface {v4, v0}, Landroid/view/SurfaceHolder;->unlockCanvasAndPost(Landroid/graphics/Canvas;)V

    goto :goto_0
.end method
